//
//  MovieCell.m
//  DSYDouban
//
//  Created by dllo on 16/1/1.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "MovieCell.h"

@interface MovieCell ()

@property (nonatomic, retain) UIImageView *backgroundImageView;

@end

@implementation MovieCell

- (void)dealloc
{
    [_backgroundImageView release];
    
    [_imgView release];
    [_titleNameLabel release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}
- (void)create {
    
    self.backgroundImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_backgroundImageView];
    [_backgroundImageView release];
    
    self.imgView = [[UIImageView alloc] init];
    [_backgroundImageView addSubview:_imgView];
    [_imgView release];
    
    self.titleNameLabel = [[UILabel alloc] init];
    [_backgroundImageView addSubview:_titleNameLabel];
    [_titleNameLabel release];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _backgroundImageView.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height - 20);
    _backgroundImageView.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    
    CGFloat background_W = _backgroundImageView.frame.size.width;
    CGFloat background_H = _backgroundImageView.frame.size.height;
    
    _imgView.frame = CGRectMake(5, 5, background_W / 3 - 10, background_H - 10);
    _imgView.backgroundColor = [UIColor greenColor];
    
    _titleNameLabel.frame = CGRectMake(background_W / 3, 0, background_W * 2 / 3 - 10, 40);
    _titleNameLabel.numberOfLines = 0;
    _titleNameLabel.center = CGPointMake(_titleNameLabel.center.x , background_H / 2);
//    _titleNameLabel.backgroundColor = [UIColor greenColor];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
